package com.youwe.web.demo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.youwe.interfaces.bu.demo.BookService;
import com.youwe.model.demo.Book;
import com.youwe.util.serializable.JSONUtils;

@RestController
@EnableAutoConfiguration
public class BookController {

	@Autowired
	private BookService bookService;
	
	@RequestMapping("/book/{id}")
	public String getBook(@PathVariable String id) {
		Book book = new Book();
		book.setId(id);
		Book returnValue = bookService.getBook(book);
		String json = JSONUtils.modelToJson(returnValue);
		return json;
	}
	
}
